package com.turing.data.scripts.contract.filter

import com.turing.common.util.FileUtils
import com.turing.common.util.StringUtils
import com.turing.data.engine.CombineLongText
import com.turing.data.engine.utils.ScriptsUtils
import com.turing.data.vo.out.review.DependParamsVO
import com.turing.data.vo.out.review.TaskElementVO

class CustodyFee_30200_10_filter {

    static List< TaskElementVO.DrawResultVO > doConvert( DependParamsVO dependParams){

        String REGEX = /.*托管费.*/

        def textPathMap = dependParams.textPathMap

        List<TaskElementVO.DrawResultVO > trueValueSet = new ArrayList<>()
        List<TaskElementVO.DrawResultVO > resultVOs = ScriptsUtils.tryInitResult(dependParams)
        if (resultVOs!=null && resultVOs.size()>0) {
            for (int i = 0; i < resultVOs.size(); i++) {
                if(StringUtils.isEmpty(resultVOs.get(i).childTaskSn)){
//                    return  resultVOs
                    continue
                }
                def rawPath = textPathMap.get(resultVOs.get(i).childTaskSn)
                def rawText = FileUtils.loadJson(rawPath)
                String trueValue = CombineLongText.fetchNearbyText(resultVOs.get(i), rawText,20)

                if (trueValue =~ REGEX  ){
                    resultVOs.get(i).setText("本计划的年托管费率为【0.01")
                    resultVOs.get(i).setBusinessValue("本计划的年托管费率为【0.01")
                    resultVOs.get(i).setType(1)
                    trueValueSet.add(resultVOs.get(i))
                    return trueValueSet
                }
            }
        }


        return  resultVOs
    }

}
